package PagePackage;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class loginPageClass extends anyPageClass {
	 
	@FindBy (name="email")
	public WebElement usernamefield;
	
	@FindBy (name="password")
	public WebElement passwordfield;
	
	@FindBy (className="button-signin")
	public WebElement loginbutton;
	
	@FindBy (xpath="html/body/div/main/section/main/form/div[2]/data-error")
	public WebElement errorWrongPassword;
	
	@FindBy (xpath="html/body/div/main/section/main/form/div[1]/data-error")
	public WebElement errorWrongEmail;
	public void setUp() throws Exception{
		baseUrl = "https://www-dev.krossover.com/intelligence-qa/login";
	}
	
	
	 public internalPageClass loginAs(String userName, String password) {
			usernamefield.sendKeys(userName);
			passwordfield.sendKeys(password);
			loginbutton.click();
			return MyPageFactory.getPage(driver, internalPageClass.class);
			
		}
	 public loginPageClass loginWithWrongCredentials(String userName, String password) {
			usernamefield.sendKeys(userName);
			passwordfield.sendKeys(password);
			loginbutton.click();
			return MyPageFactory.getPage(driver, loginPageClass.class);
			
		}
	/* public boolean isOnThisPage(){
			return usernamefield.isDisplayed();
		}*/
	 @Override
	void tryToOpen() {
		//MyPageFactory.getPage(driver, loginPageClass.class).loginAs("victoria@krossover.com", "webmaster");
	
		 MyPageFactory.getPage(driver, internalPageClass.class).logout();
	}

}
